﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DSS_XNA.Engine.Error;
using DSS_XNA.Engine.Script;
using DSS_XNA.Engine.Entities;

namespace DSS_XNA.Engine.Script.Commands
{
    public class ScriptCommand_AddEvent
    {
        #region Static Methods

        public static void Action(Dictionary<string, string> args, ScriptManager manager, Game1 engine)
        {
            if (!args.ContainsKey("name"))
                throw new DSSException("No Name parameter for AddEvent");
            if (!args.ContainsKey("type"))
                throw new DSSException("No Type parameter for AddEvent");
            if (!args.ContainsKey("action"))
                throw new DSSException("No Action parameter for AddEvent");

            string name = manager.GetParameterValue(args["name"]).ToString();
            string type = manager.GetParameterValue(args["type"]).ToString();
            string action = args["action"]; // we don't want to call manager.GetParameterValue here because any value here is to be evaluated at the time of execution (although maybe a function could be here that will return some script... we will implement that another day)

            engine.ObjectManager.AddEvent(type, name, action);
        }

        #endregion
    }
}
